<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>按键触发操作</title>
	</head>
	<body>
		
		 <div id="app">
			<h1>我是一个计算器</h1>
			<span>数字1：</span>{{num}}
			<input type="text" v-model="num"><br/>
			<span>数字2：</span>{{num2}}
			<input type="text" v-model="num2" @keyup.enter="addNum"><br/>
			<span>总和：</span> {{count}}
			
			<button @click="addNum">求和</button>
			
		 </div>
		 <!-- 1.导入js文件-->
		 <script src="../js/vue.js"> </script>
		 <!-- 3.创建vue对象-->
		 <script>
			 
			const APP =new Vue({
				//1.注定区域
				el: "#app",
				data: {
					num:0,
					num2:0,
					count:0
				},
				methods:{
					addNum(){
						this.count=parseInt(this.num)+parseInt(this.num2)
						//一定要写this
					}
				}
				
			})
		 </script>
	</body>
</html>
